home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / GXDEVMEM.H < prev    next >
C/C++ Source or Header  |  1992-03-05  |  4KB  |  92 lines

  1. /* Copyright (C) 1989, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gxdevmem.h */
  21. /* "Memory" device structure for Ghostscript library */
  22. /* Requires gxdevice.h */
  23.  
  24. /*
  25.  * A 'memory' device is essentially a stored bitmap.
  26.  * There are several different kinds: 1-bit black and white,
  27.  * 2-, 4-, and 8-bit mapped color, and 16-, 24-, and 32-bit true color.
  28.  * (16-bit uses 5/6/5 bits per color.  24- and 32-bit are equivalent:
  29.  * 24-bit takes less space, but is slower.)  All use the same structure,
  30.  * since it's so awkward to get the effect of subclasses in C.
  31.  *
  32.  **********************************************************
  33.  ******* 2- and 4-BIT DEVICES ARE NOT SUPPORTED YET *******
  34.  **********************************************************
  35.  *
  36.  * On little-endian machines, the bytes can be stored in either order.
  37.  * Little-endian order is the default, since this allows efficient
  38.  * updating; big-endian is required if the bits will be used as the
  39.  * source for a rendering operation (e.g., in the character cache).
  40.  * We provide an operation to normalize the byte order, and we trust the
  41.  * client not to do any rendering operations if the byte order is
  42.  * reversed.
  43.  */
  44. typedef struct gx_device_memory_s gx_device_memory;
  45. struct gx_device_memory_s {
  46.     gx_device_common;        /* (see gxdevice.h) */
  47.     gs_matrix initial_matrix;    /* the initial transformation */
  48.     uint raster;            /* bytes per scan line, */
  49.                     /* filled in by '...bitmap_size' */
  50.     byte *base;
  51.     byte **line_ptrs;        /* scan line pointers */
  52.     int bytes_le;            /* chunk size (2 bytes) if */
  53.                     /* bytes are stored in */
  54.                     /* little-endian order, else 0 */
  55.     /* Following is only needed for monochrome */
  56.     int invert;            /* 0 if 1=white, -1 if 1=black */
  57.     /* Following are only needed for mapped color */
  58.     int palette_size;        /* # of entries */
  59.     byte *palette;            /* RGB triples */
  60. };
  61. extern gx_device_memory
  62.     mem_mono_device,
  63.     mem_mapped8_color_device,
  64.     mem_true16_color_device,
  65.     mem_true24_color_device,
  66.     mem_true32_color_device;
  67.  
  68. /* Memory devices may have special setup requirements. */
  69. /* In particular, it may not be obvious how much space to allocate */
  70. /* for the bitmap.  Here is the routine that computes this */
  71. /* from the width and height in the device structure. */
  72. extern ulong gdev_mem_bitmap_size(P1(const gx_device_memory *));
  73.  
  74. /* Determine the appropriate memory device for a given */
  75. /* number of bits per pixel (0 if none suitable). */
  76. extern gx_device_memory *gdev_mem_device_for_bits(P1(int));
  77.  
  78. /* Test whether a device is a memory device. */
  79. extern int gs_device_is_memory(P1(const gx_device *));
  80.  
  81. /* Ensure that the data bytes are in big-endian order. */
  82. /* This is only needed when the bitmap will be used as the source */
  83. /* for a copy_mono operation, and is only used for the character cache */
  84. /* and similar RAM-resident devices. */
  85. extern void gdev_mem_ensure_byte_order(P1(gx_device_memory *));
  86.  
  87. /*
  88.  * A memory device is guaranteed to allocate the bitmap consecutively,
  89.  * i.e., in the form that can serve as input to copy_mono or copy_color
  90.  * operations (provided that the bytes are in big-endian order, of course).
  91.  */
  92.